# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).

# Administrator
User.delete_all("login = 'admin'")

admin = User.create!(:login=>'admin', :name=>'Administrator', :password=>'localhost', :password_confirmation=>'localhost', :email=>'superp1987@gmail.com')
admin.register!
admin.activate!
puts "User created: :login=>#{admin.login}, :password=>#{admin.password}"

# Role
admin.has_role!('superadmin')

# Structures
Structure.truncate_translation_table!
Structure.connection.execute("TRUNCATE TABLE #{Structure.table_name};")

main = Structure.create!(:title=>"Главная страница", :title_en=>"Main page", :slug=>"main", :kind=>:main)

about = Structure.create!(:title=>"О клубе", :title_en=>"About club", :slug=>"about", :kind=>:page, :proposed_parent=>main, :position=>1)
gallery = Structure.create!(:title=>"Галерея", :title_en=>"Gallery", :slug=>"gallery", :kind=>:gallery, :proposed_parent=>main, :position=>2)
services = Structure.create!(:title=>"Услуги", :title_en=>"Services", :slug=>"services", :kind=>:services, :proposed_parent=>main, :position=>3)
team = Structure.create!(:title=>"Наша команда", :title_en=>"Our team", :slug=>"team", :kind=>:page, :proposed_parent=>main, :position=>4)
contacts = Structure.create!(:title=>"Контакты", :title_en=>"Contacts", :slug=>"contacts", :kind=>:page, :proposed_parent=>main, :position=>5)

posts = Structure.create!(:title=>"Новости", :title_en=>"News", :slug=>"news", :kind=>:posts, :proposed_parent=>main, :is_visible=>false)

index_page = Structure.create!(:title=>"Текст на главной", :title_en=>"Main text", :slug=>"index_page", :kind=>:page, :proposed_parent=>main, :is_visible=>false)

people = Structure.create!(:title=>"Тренеры", :title_en=>"Coaches", :slug=>"coaches", :kind=>:coaches, :proposed_parent=>team, :is_visible=>false)

#courts = Structure.create!(:title=>"Теннисные корты", :title_en=>"Tennis Courts", :slug=>"tennis_courts", :kind=>:page, :proposed_parent=>services, :position=>1)
#kinezis = Structure.create!(:title=>"Кинезис", :title_en=>"Kinezis", :slug=>"kinezis", :kind=>:page, :proposed_parent=>services, :position=>2)
#pool = Structure.create!(:title=>"Бассейн", :title_en=>"Pool", :slug=>"pool", :kind=>:page, :proposed_parent=>services, :position=>3)
#consultancy = Structure.create!(:title=>"Услуги консультанта", :title_en=>"Consultancy", :slug=>"consultancy", :kind=>:page, :proposed_parent=>services, :position=>4)
#gyms = Structure.create!(:title=>"Тренажерные залы", :title_en=>"Gyms", :slug=>"gyms", :kind=>:page, :proposed_parent=>services, :position=>5)
#massage = Structure.create!(:title=>"Массаж", :title_en=>"Massage", :slug=>"massage", :kind=>:page, :proposed_parent=>services, :position=>6)

